﻿using System;
using UnityEngine;

public class PlayerCamera : MonoBehaviour
{
    [SerializeField]
    private Camera m_cam;
    public Vector3 offset;
    public float speed = 5f;
    public Transform target;
    private Vector3 targetPos;

    public void SetTargetImmediately(Transform value)
    {
        this.target = value;
        this.Update(10000f);
    }

    private void Update()
    {
        this.Update(this.speed);
    }

    private void Update(float speed)
    {
        if (this.target != null)
        {
            this.targetPos = this.target.position + this.offset;
        }
        base.transform.position = Vector3.Lerp(base.transform.position, this.targetPos, Time.deltaTime * speed);
    }

    public Camera cam
    {
        get
        {
            return this.m_cam;
        }
    }
}

